package com.mj.haier.calc.servlet.impl;

import java.io.IOException;
import java.time.Instant;

import com.mj.haier.calc.domain.AzEorderSettlementProcess;
import com.mj.haier.calc.repository.AzEorderSettlementProcessRepository;
import com.mj.haier.calc.servlet.Request;
import com.mj.haier.calc.servlet.Response;
import com.mj.haier.calc.servlet.Servlet;
import com.mj.haier.calc.servlet.ServletException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class UpdateServletAzEorderSettlmentProcess implements Servlet{

    private final Logger log = LoggerFactory.getLogger(UpdateServletAzEorderSettlmentProcess.class);

    private final AzEorderSettlementProcessRepository azEorderSettlementProcessRepository;

    public UpdateServletAzEorderSettlmentProcess(AzEorderSettlementProcessRepository azEorderSettlementProcessRepository){
        this.azEorderSettlementProcessRepository = azEorderSettlementProcessRepository;
    }


    @Override
    public void servlet(Request req, Response res) throws IOException, ServletException {
        
        AzEorderSettlementProcess azEorderSettlementProcess = (AzEorderSettlementProcess)req.getObject();
        if(null != azEorderSettlementProcess && null != azEorderSettlementProcess.getId()){
            azEorderSettlementProcess.modifiedUser("AzEorderSettlementProcessRepository servlet")
                .gmtModified(Instant.now());
            azEorderSettlementProcessRepository.save(azEorderSettlementProcess);
            log.debug("当前此ID保存成功:{}", azEorderSettlementProcess.getId());
        }
    }
}